import EditorConsole from '../components/EditorConsole'
import WebPlayer from '../components/WebPlayer'
import { classExample, extendsExample } from '../examples/classes'


In ES5, "classes" are typically written as normal functions, e.g. `function MyClass() {...}`, with instance methods assigned to `MyClass.prototype`. ES2015 allows us to use the simpler `class` syntax.

`class` gives us built in instance functions, static functions, and inheritance. `constructor` is a special function that is called automatically every time a class instance is created. We can use the `static` keyword to declare static class functions. Static method calls are made directly on the class and cannot be called on instances of the class.

<EditorConsole {...classExample} height={480} />

# Inheritance

`class` gives us simple inheritance with the keyword `extends`. Classes that inherit from a parent have access to respective parent functions via `super`.

<EditorConsole {...extendsExample} height={480} />

For full details on the `class` syntax, see the MDN reference for [class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes).
